<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
	<title>订单详情</title>
	<link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/css/base.css">
	<link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/mobile/css/master.css">
	<style>
	.share{ position:fixed;width:100%;height:100%;top:0px;left:0px;background:rgba(0,0,0,0.6);display:none;z-index:10;}
	.share .image{background:url("/Public/mobile/images/shareToFriend2.png") no-repeat right top;background-size:100%;height:80%;}

	#shareMinus{position:fixed;top:0px;left:0px;right:0px;bottom:0px;margin:auto;width:200px;height:60px;line-height:30px;padding:10px 0;text-align:center;background:rgba(0,0,0,0.6);color:#fff;font-size:14px;border-radius:5px;box-shadow:0 0 6px #666;display:none;text-align:center;overflow:hidden;
		-webkit-transition: all 0.4s ease-out;}
	#shareMinus em{font-size:32px;color:#f60;display:block;}
	#shareMinus.hidden{left:-200px;top:100%;width:0px;height:0px;}
	.coupon input{border: 1px solid #eee;padding: 10px;width: 72%;box-sizing:border-box;background:#f8f8f8;}
	.coupon button{padding: 10px 10px;box-sizing: border-box;background: #4ACCF1;color: #fff;position: relative;top:1px;border:0px;width:26%;font-size:14px;}

	</style>
</head>
<body>
	<header class="tcenter fs14">
        <a href="tel:4006730088" class="tel iconfont">&#xe610;</a>
        <a href="{:C('WEB_URL')}mobile/" class="iconfont fright">&#xe60f;</a>
        <a href="javascript:window.history.go(-1)" class="iconfont fleft">&#xe612;</a>
        订单详情
    </header>
	
	<div class="wrap" id="order">
		<div class="orderMain">
			<p class="code"><em>{$orderStatus[$order['status']]}</em>订单号：{$order['order_num']}</p>
			<div class="auto">
				<img src="http://app2.haixiuyizhan.com/{$order['brand_logo']}" />
				<p class="name">{$order['brand_name']}&nbsp;{$order['model_name']}&nbsp;{$order['model_pl']}&nbsp;{$order['model_year']}</p>
			</div>
		</div>
		<div class="orderInfo">
			<dl>
				<notempty name="company">
					<dt>安装维修厂</dt>
					<dd class="orderCompany">
						<img src="http://m.99qby.com/Public/images/getheadimg.jpg" />
						<p class="name">去保养</p>
						<p class="address">杭州市萧山区萧杭路291号</p>
					</dd>
				</notempty>

				<dt class="">异常部位报告</dt>
				<dd class="break ">
					<ul class="clearfix">
						<?php if($log){ $break=1; foreach($log as $l){ if($l['bad_level']!=1){ $break=0; ?>
						<li class="level<?php echo $l['bad_level']; ?>">
							<em><i><?php if($l['bad_level']==5){echo '预警';}else{echo '异常';} ?></i></em>
							<p class="name"><?php echo $l['name']; ?><br /><span><?php echo $l['biaozhun']; ?></span></p>
							<p class="val">
								<?php if($l['bad_level']==5){echo '建议更换';}else{echo '必须更换';} ?>
								<em>检测值：<?php echo $l['val']; ?></em>
							</p>
						</li>
						<?php }} if($break){ echo '无损坏';} }else{echo '未检测';} ?>
					</ul>
				</dd>

				<dt>保养配件</dt>
				<dd class="part">
					<ul>
						<volist name="partList" id="vo">
							<li>
								<img src="http://app2.haixiuyizhan.com/{$vo['logo']}" />
								<p class="name">{$vo['pj_name']}</p>
								<p class="count">数量：{$vo['count']}</p>
								<p class="price"><em>￥{$vo['pj_csprice']}</em> <span>￥{$vo['pj_scprice']}</span></p>
								<php>$totle+=($vo['pj_csprice']*$vo['count']);</php>
							</li>
						</volist>
						<notempty name="order['service_price']">
							<li>
								<img src="{:C('WEB_URL')}Public/mobile/images/server.png" />
								<p class="name">{$order['order_name']}服务费</p>
								<p class="count hide">包含：洗车、138项安全检测、咖啡饮品</p>
								<p class="price mt10"><em>￥{$order['service_price']}</em></p>
							</li>
						</notempty>
					</ul>
					<p class="total">配件总价：<em>￥{$totle+$order['service_price']}</em></p>
					<notempty name="order['privilege']">
						<p class="couponPrice">优惠：<em>{$order['privilege']}</em></p>
					</notempty>

				</dd>
				

				<notempty name="comment">
					<dt>评论</dt>
					<dd class="log">
						<i>&#xe613;</i>{$comment['create_time']|date='Y-m-d H:i',###}
						<notempty name="comment['commentTxt']">
							<p class="fs12 fc-999">评价内容：{$comment['commentTxt']}</p>
						</notempty>
					</dd>
				</notempty>

			</dl>
	
			<php>if($order['pay_type']!=0&&empty($comment)){</php>
				<a href="{:U('comment')}?order_id={$order['order_id']}" class="btnBlue" id="J_btnComment">评价</a>
			<php>}</php>
			

		</div>
		<php>if($order['status']==50){ </php>
		<div class="live">
			<a href="{:C('WEB_URL')}mobile/live/"><i>&#xe627;</i>观看直播</a>
			您的爱车正在保养中...
		</div>
		<php>}elseif($order['pay_type']==0){</php>
				<eq name="order.pay_type" value="0">
				<div class="pay">
			        <div class="index">
			        	<p class="price"><span class="mPrice">￥{$order['total_price']}</span>
			        	<em id="J_price">￥{$order['all_price']}</em></p>
			        	<php>if($Server=="wx"&&$order['pay_type']==0&&$order['privilege']==""&&$order['status']==60){ $shareStatus="false";</php>
			        		<p class="txt" onclick="share.show()">分享立减224元</p>
			        	<php>}else{
			        		$shareStatus="true";
			        	}</php>
			        </div>
			        <eq name="Server" value="wx">
						<a href="javascript:callpay()" data-id="{$order['order_id']}" id="J_btnGoStep1" >立即支付</a>
			        <else />
						<a href="/mobile/alipaywap?info=1&order_id='{$order['order_id']}" id="J_btnGoStep1" >立即支付</a>
			        </eq>
			        
			    </div>
			</eq>
		<php>}</php>
	</div>
	


	<div id="shareMinus">
		操作成功<em>￥{$order['all_price']}</em>
	</div>
	<div class="share" onclick="share.hide()">
		<div class="image">
			
		</div>
	</div>
	
	<include file="Public/mobileHome" />
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
	<script type="text/javascript">

		//分享至朋友圈立减
		var share={
			dom:$(".share"),
			payStatus:"{$shareStatus}",	//是否点过支付
			shareStatus:0,	//是否分享过
			show:function(type){
				if(type=="pay"){
					this.payStatus=true;
				}
				this.dom.show();
			},
			hide:function(){
				this.dom.hide();
			},
			share:function(){
				var _t=this;
				$.ajax({
					type:"post",
					dataType:"json",
					data:{"id":getQuery("id")},
					url:"/mobile/privilegeShareSummer.html",
					success:function(res){
						if(res.status==1){
							$(".share").hide();
							$(".index > .txt").hide();	//隐藏分享文字
							_t.shareStatus=1;	//改变状态为已分享
							_t.printCoupon();
						}
						//window.history.go(0);
					}
				})
			},

			//优惠输出及减价动画
			printCoupon:function(){
				$(".total").after('<p class="couponPrice">优惠：<em>分享朋友圈立减224元</em></p>');
				var price=$("#J_price").html().replace(/\D/g,"")*1,
					transition=$("#shareMinus > em"),
					val=0;
				$("#shareMinus").show();
				$("#J_price").html("￥"+(price-224));

				minus();

				function minus(){
					if(val<=224){	//减10元
						setTimeout(function(){
							transition.html("￥"+(price-val));
							val=val+4;
						 	minus();
						},80);
					}else{
						setTimeout(function(){
							$("#shareMinus").addClass("hidden");
						},800);
						
					}
				}
				
			}
		}
		var WEB_URL="{:C('WEB_URL')}";
		$(function(){
			
			wx.config({
			    debug: false,
			    appId: "{:C('weixinAppId')}", // 必填，公众号的唯一标识
			    timestamp:'{$signatureTime}' , // 必填，生成签名的时间戳
			    nonceStr: '{$nonceStr}', // 必填，生成签名的随机串
			    signature: '{$signature}',// 必填，签名
			    jsApiList: ["onMenuShareTimeline","onMenuShareAppMessage"] // 必填，需要使用的JS接口列表
			});
			wx.ready(function(){
				wx.onMenuShareTimeline({
				    //title: "我的{$auto['brand_name']}今天做了保养才{$order['all_price']-10}元！！以前4S店要{$order['total_price']}元！好便宜，太赞了！!", // 分享标题
				    title:"空调清洗仅1元，赶紧给爱车的空调洗洗澡吧！",
				    link: WEB_URL+'mobile/share2.html?id={$_GET["id"]}', // 分享链接
				    imgUrl: WEB_URL+'Public/mobile/images/summer.jpg', // 分享图标
				    success: function () {
				    	if(share.shareStatus==0){
				        	share.share();
				        }
				    },
				    cancel: function () {
				        //alert("分享取消");
				    }
				});

				wx.onMenuShareAppMessage({
				    title: '去保养-爱车养护互联网式新体验！', // 分享标题
				    desc: "我的{$order['brand_name']}保养只要{$order['all_price']-10}元！4S店的一半！！还体验了一把互联网思维的维修厂：保养在线观看！咖啡馆做保养！上门取车保养！下班夜间保养！", // 分享描述
				    link: WEB_URL+'mobile/share.html?id={$_GET["id"]}', // 分享链接
				    imgUrl: WEB_URL+'Public/mobile/images/summer.jpg', // 分享图标
				    type: '', // 分享类型,music、video或link，不填默认为link
				    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
				    success: function () { 
				        // 用户确认分享后执行的回调函数
				    },
				    cancel: function () {
				        // 用户取消分享后执行的回调函数
				    }
				});
				

			})
		})

		//调用微信JS api 支付
		function jsApiCall(jsApiParameters){

	        $("#loading").hide();
			WeixinJSBridge.invoke(
				'getBrandWCPayRequest',
				jsApiParameters,
				function(res){
					WeixinJSBridge.log(res.err_msg);
					//alert(res.err_code+res.err_desc+res.err_msg);
					if(res.err_msg=="get_brand_wcpay_request:ok"){
						//location.reload();
						window.location.href="{:U('comment')}?order_id={$order['order_id']}";
					}
				}
			);
		}

		function callpay(){
			if(share.payStatus==="false"){
				share.show("pay");
				return ;
			}
			$.ajax({
                type:"post",
                url:"{:C('WEB_URL')}mobile/pay/type/1/order_id/{$order['order_id']}",
                data:{"qwe":"123"},
                dataType:"json",
                success:function(res){
        			if (typeof WeixinJSBridge == "undefined"){
        			    if( document.addEventListener ){
        			        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
        			    }else if (document.attachEvent){
        			        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
        			        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
        			    }
        			}else{
        			    jsApiCall(res);
        			}
                }
            })

		}	

		function getCoupon(){
			var code=$("input[name='coupon']").val();
            //if(!/\d{16}/.test(code)){
            if(code==""){
                showMsgTip("请输入正确的优惠码",2000);
                return false;
            }
			
			var price=$("#J_price").html().replace(/\D/g,"")*1,
				transition=$("#shareMinus > em"),
				money=0,
				val=0;
			$.ajax({
				url:"{:C('WEB_URL')}mobile/userCoupon/",
				type:"post",
				dataType:"json",
				data:{"code":code,"orderId":getQuery("id")},
				success:function(res){
					if(res.status==1){
						money=res.data['money'];
						$(".total").after('<p class="couponPrice">优惠：<em>使用代金券立减'+money+'元</em></p>');
						$("#shareMinus").show();
						$("#J_price").html("￥"+(price-money));
						minus();
						$(".J_coupon").hide();
					}else{
						showMsgTip(res.info,2000);
                		return false;
					}
				}
			})
			
			function minus(){
				if(val<=money){	//减10元
					setTimeout(function(){
						transition.html("￥"+(price-(val++)));
					 	minus();
					},50);
				}else{
					setTimeout(function(){
						$("#shareMinus").addClass("hidden");
					},800);
					
				}
			}
		}


	</script>
</body>
</html>